package pailaidai.hc.com.mysvgdemo.util;

import android.annotation.SuppressLint;
import android.content.Context;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.text.TextUtils;

/**
 * Created by Administrator on 2018/4/20.
 */

public class AppUtils {
    /**
     * 获取手机唯一设备ID
     * */
    public static String getDeviceID(Context context) {
        TelephonyManager mTm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        @SuppressLint("MissingPermission")
        String imei = mTm.getDeviceId();
//        String imsi = mTm.getSubscriberId();
        String mtype = Build.MODEL; // 手机型号
        String mtyb = Build.BRAND;//手机品牌
//        String numer = mTm.getLine1Number(); // 手机号码，有的可得，有的不可得
        String sversion = Build.VERSION.RELEASE;//系统版本
//        String mobileName = Build.USER;
        WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        String m_szWLANMAC = wm.getConnectionInfo().getMacAddress();
        String serialNumber = Build.SERIAL;
        if (!TextUtils.isEmpty(imei) && !TextUtils.isEmpty(m_szWLANMAC)) {
            return imei + m_szWLANMAC;
        } else if (!TextUtils.isEmpty(imei)) {
            return imei;
        } else if (!TextUtils.isEmpty(m_szWLANMAC)) {
            return  m_szWLANMAC;
        } else if (!TextUtils.isEmpty(serialNumber)) {
            return serialNumber;
        }
        return "123456789";
    }

}
